<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>01万花筒</title>
		<style type="text/css">
			#firCan {
				display: block;
				border: 1px solid khaki;
				margin: auto;
			}
		</style>
	</head>
	<body>
		<canvas id="firCan" width="1000" height="625">
			您的浏览器版本过低, 不支持Canvas, 请升级!
		</canvas>
	</body>
	<script type="text/javascript">
		// 1, 获取Canvas
		var firCan = document.getElementById("firCan");
		// 2, 获取 2d渲染上下文
		var context = firCan.getContext('2d');
		// 3, 加载图片
		// 创建 img对象
		var imgObj = new Image();
		// 设置 src
		imgObj.src = "img/banner3.png";
		// 图片加载完毕
		imgObj.onload = function() {
			// 图片绘制到 canvas: drawImage()
//			context.drawImage(imgObj, 0, 0, 1280, 800, 0, 0, 1000, 625);
			
			// 左上角
			context.drawImage(imgObj, 700, 300, 300, 300, 100, 100, 200, 200);
			
			// 左下角
			context.setTransform(1, 0, 0, -1, 0, 600);
			context.drawImage(imgObj, 700, 300, 300, 300, 100, 100, 200, 200);
			
			// 右上角
			context.setTransform(-1, 0, 0, 1, 600, 0);
			context.drawImage(imgObj, 700, 300, 300, 300, 100, 100, 200, 200);
			
			// 右下角
			context.setTransform(-1, 0, 0, -1, 600, 600);
			context.drawImage(imgObj, 700, 300, 300, 300, 100, 100, 200, 200);
		}
		
		
		
	</script>
</html>
